<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>

</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷中业务>车辆资料复审</span>
		<a href="javascript:void(0)"></a>
	</div>
	<div class="ibox-content ibox-con">
	<div class="buttonfixed">
       <button type="button" class="btn dpbtn_blue" id="save">保存</button>
       <button type="button" class="btn dpbtn_blue" id="commit">提交</button>
    </div>
		<form class="form-horizontal" id="commentForm">
		<%@include file="/jsp/common_yw_with_loan_include.jsp"%>
		<div class="business-manwife">提车信息</div>
		<div class="business-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="infor-table">
				<tr>
					<td align="right">
						<label class="control-label np">提车/过户时间：</label>
					</td>
					<td>
						<div class="control-div np" id="pickCarTime"><fmt:formatDate value='${empty dzPickCar.pickCarTime ? ywTransfer.dateTransfer : dzPickCar.pickCarTime}' pattern='yyyy-MM-dd HH:mm'/></div>
					</td>
				</tr>
			</table>
		</div>
		
		<!-- 车辆信息 -->
		<div class="business-manwife">车辆信息</div>
           	<div class="padding-nono">
		        <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
		        <input id="id" name="id" type="hidden" value="${fkTmpCarRecheck.id }">
				<input id="carId" name="carId" type="hidden" value="${ywBusinessCar.id }">
				<tr>	
					<td align="right">
						<label class="control-label np">车辆类别：</label>
					</td>
					<td>
						<mytag:selectTag id="categoryCar" name="categoryCar" map="${carCategoryType }" selected="${ywBusinessCar.categoryCar}" others="class='select-control' disabled='disabled'"/>
					</td>
					<td align="right">
						<label class="control-label np">车辆颜色：</label>
					</td>
					<td>
						<mytag:selectTag id="colorCar" name="colorCar" map="${carColorType }" selected="${empty fkTmpCarRecheck.colorCar ? ywBusinessCar.colorCar : fkTmpCarRecheck.colorCar}" others="class='select-control' required='required'"/>
					</td>
					<td align="right">
						<label class="control-label np">合格证号：</label>
					</td>
					<td>
						<input id="numQualified" required="required" placeholder="合格证号(必填)" name="numQualified" class="form-control" value="${empty fkTmpCarRecheck.numQualified ? ywBusinessCar.numQualified : fkTmpCarRecheck.numQualified}" />
					</td>
				</tr>
				<tr>		
					<td align="right"><label class="control-label np">车辆车型：</label>
					<td colspan="3">
						<input type="text" placeholder="请输入汽车品牌(必填)" required="required" id="carName" class="form-control smalliconcur smallicon" name="carName" value="${empty fkTmpCarRecheck.nameCarModel ? ywBusinessCar.nameCarModel : fkTmpCarRecheck.nameCarModel}" onclick="carcho(false,this.value);" /> 
						<input type="hidden" id="carModel" name="carModel" value="${empty fkTmpCarRecheck.carModel ? ywBusinessCar.carModel : fkTmpCarRecheck.carModel}" /> 
						<input id="carBrand" name="carBrand" type="hidden" value="${empty fkTmpCarRecheck.carBrand ? ywBusinessCar.carBrand : fkTmpCarRecheck.carBrand}" /> 
						<input id="carSeries" name="carSeries" type="hidden"  value="${empty fkTmpCarRecheck.carSeries ? ywBusinessCar.carSeries : fkTmpCarRecheck.carSeries}"/> 
						<input type="hidden" id="nameCarModel" name="nameCarModel" value="${empty fkTmpCarRecheck.nameCarModel ? ywBusinessCar.nameCarModel : fkTmpCarRecheck.nameCarModel}" /> 
						<input id="nameCarBrand" name="nameCarBrand" type="hidden"  value="${empty fkTmpCarRecheck.nameCarBrand ? ywBusinessCar.nameCarBrand : fkTmpCarRecheck.nameCarBrand}" /> 
						<input id="nameCarSeries" name="nameCarSeries" type="hidden" value="${empty fkTmpCarRecheck.nameCarSeries ? ywBusinessCar.nameCarSeries : fkTmpCarRecheck.nameCarSeries}" />
						<input id="carId" name="carId" type="hidden">
						<input id="priceNewcar"  type="hidden" />
					</td>
					<td align="right">
						<label class="control-label np">车架号：</label>
					</td>
					<td>
						<input id="vin" required="required"  onblur="changenumEngine();" placeholder="车架号(必填)" name="vin" class="form-control" value="${empty fkTmpCarRecheck.vin ? ywBusinessCar.vin : fkTmpCarRecheck.vin}" />
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">厂牌型号：</label>
					</td>
					<td>
						<input id="noticeModel" name="noticeModel" required="required" placeholder="厂牌型号(必填)" class="form-control" value="${empty fkTmpCarRecheck.noticeModel ? ywBusinessCar.noticeModel : fkTmpCarRecheck.noticeModel}" />
					</td>
					<td align="right">
						<label class="control-label np">排量(L)：</label>
					</td>
					<td>
						<input id="displacement" name="displacement" required="required" placeholder="排量(必填)" class="form-control" value="${empty fkTmpCarRecheck.displacement ? ywBusinessCar.displacement : fkTmpCarRecheck.displacement}" />
					</td>
					
					<td align="right">
						<label class="control-label np">功率：</label>
					</td>
					<td>
						<input id="power" name="power"  class="form-control" required="required" placeholder="功率(必填)" value="${empty fkTmpCarRecheck.power ? ywBusinessCar.power : fkTmpCarRecheck.power }" />
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">发动机号：</label>
					</td>
					<td>
						<input id="numEngine" name="numEngine"  required="required" placeholder="发动机号(必填)"  class="form-control"  value="${empty fkTmpCarRecheck.numEngine ? ywBusinessCar.numEngine  : fkTmpCarRecheck.numEngine}" />
					</td>
					
					<td align="right">
						<label class="control-label np">底盘后6位：</label>
					</td>
					<td>
						<input id="numChassisSix" name="numChassisSix" readonly="readonly" class="form-control" type="text" maxlength="6" minlength="6" required="required" placeholder="底盘后6位(必填)"  value="${empty fkTmpCarRecheck.numChassisSix ? ywBusinessCar.numChassisSix  : fkTmpCarRecheck.numChassisSix}" />
					</td>
					<td align="right">
						<label class="control-label np">开票单位：</label>
					</td>
					<td>
						<input id="companyBill" name="companyBill" class="form-control" required="required" placeholder="开票单位(必填)" value="${empty fkTmpCarRecheck.companyBill ? ywBusinessCar.companyBill  : fkTmpCarRecheck.companyBill}" />
					</td>
				</tr>
				
				<tr>	
					<td align="right">
						<label class="control-label np">发票日期：</label>
					</td>
					<td>
						<input id="dateBill" required="required" placeholder="发票日期(必填)" name="dateBill" class="laydate-icon form-control" value="<fmt:formatDate value='${empty fkTmpCarRecheck.dateBill ? ywBusinessCar.dateBill  : fkTmpCarRecheck.dateBill}' pattern='yyyy-MM-dd'/>" />
					</td>
					
					<td align="right">
						<label class="control-label np">发票号：</label>
					</td>
					<td>
						<input id="numBill" name="numBill" required="required" placeholder="发票号(必填)"  class="form-control" value="${empty fkTmpCarRecheck.numBill ? ywBusinessCar.numBill  : fkTmpCarRecheck.numBill}" />
					</td>
					<td align="right">
						<label class="control-label np">发票地区：</label>
					</td>
					<td>
						<input id="areaBill" name="areaBill" required="required" placeholder="发票地区(必填)" class="form-control" value="${empty fkTmpCarRecheck.areaBill ? ywBusinessCar.areaBill  : fkTmpCarRecheck.areaBill}" />
					</td>
				</tr>
				
				<tr>	
					<td align="right">
						<label class="control-label np">开票价格：</label>
					</td>
					<td>
						<input id="price" readonly="readonly" required="required" placeholder="开票价格(必填)" name="price" class="form-control" value='<fmt:formatNumber type="number" value="${empty fkTmpCarRecheck.price ? ywBusinessCar.price  : fkTmpCarRecheck.price}" pattern="0.00" maxFractionDigits="2"/>' />
					</td>
				</tr>
			</table>	
		</div>	
	</form>
</div>	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
 	<!-- 车品牌/车型/车系选择 -->
 	<%@include file="/jsp/comm_js_carModel_include.jsp"%>
 	<!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    <!-- 区域选择 -->
 	<%-- <%@include file="/jsp/comm_js_region_include.jsp"%> --%>
    <%@include file="/jsp/carchoice_js_include.jsp"%>
    
    <script type="text/javascript"></script>
    <!--
    	作者：xiongxiaotun
    	时间：2017-08-02
    	描述：车辆资料复审
    -->
<script type="text/javascript">
	 $(function(){
    	$("#commentForm").validate({
            //重写showErrors
            showErrors: function (errorMap, errorList) {
                $.each(errorList, function (i, v) {
                    layer.tips(v.message, v.element, { time: 1500 });
                    return false;
                });  
            },
            /* 失去焦点时验证 */
            onfocusout: function(element) { $(element).valid(); },
            /*  键盘抬起不验证 */
            onkeyup:false,
        }); 
    	
    	 $('#save').click(function(){
	        	save(false);
	     });
    	 $('#commit').click(function(){
    		 var validstatus = $("#commentForm").valid();
    		 if(validstatus){
	        	save(true);
    		 }else{
 				layer.msg("有验证未通过，请仔细检查！", {icon: 5});
 			}	
	     });
	 	var dateBill = {
   			  elem: '#dateBill', 
 		      event: 'focus' ,
   			  format: 'YYYY-MM-DD',
   			  max: '2099-06-16', //最大日期
   			  istime: false,
   			  istoday: false
   			};
	        laydate(dateBill);
	   });
	    
	   function changenumEngine(){
	    	var vin = $("#vin").val();
	    	var len = vin.length;
	    	var numChassisSix = vin.substring(len,len-6);
	    	$("#numChassisSix").val(numChassisSix)
	    }
	
	    //保存/提交
	    function save(commit){
	    	commit = commit || false;
	    	var data = {};
	    	//基本字段
	    	data.id = $('#id').val();
	    	data.carId = $('#carId').val();
	    	data.registrationId = $('#registrationId').val();
	    	data.busiId = $("#busiId").val();
			data.cusId = $("#customerId").val();
			
	    	//辅助字段
	    	data.commit = commit;
	    	//车辆信息
			data.busiId = $("#busiId").val();
			data.cusId = $("#customerId").val();
			data.colorCar = $('#colorCar').val();
			data.numQualified = $('#numQualified').val();
			data.vin = $('#vin').val();
			
			data.carName = $("#carName").val() ;
			data.carBrand = $("#carBrand").val() ;
			data.nameCarBrand = $("#nameCarBrand").val();
			data.carSeries = $("#carSeries").val();
			data.carModel = $("#carModel").val();
			data.nameCarSeries = $("#nameCarSeries").val();
			data.nameCarModel = $("#nameCarModel").val();
			data.carId = $("#carId").val();
			
			data.noticeModel = $('#noticeModel').val();
			data.displacement = $('#displacement').val();
			data.power = $('#power').val();
			data.vin = $('#vin').val();
			data.numEngine = $('#numEngine').val();
			data.numChassisSix = $('#numChassisSix').val();
			data.companyBill = $('#companyBill').val();
			data.dateBill = $('#dateBill').val();
			data.numBill = $('#numBill').val();
			data.areaBill = $('#areaBill').val();
			data.price = $('#price').val();
			
			//车牌信息
			/* data.provinceRegistration = $("#province").val();
			data.areaRegistration = $('#city').val();
			data.dvm = $('#dvm').val();
			data.licensePlate = $('#licensePlate').val();
			data.registrationNumber = $('#registrationNumber').val();
			data.dateRegistrationFirst = $('#dateRegistrationFirst').val();
			data.dateRegistrationNow = $('#dateRegistrationNow').val();
			data.remark = $('#remark').val(); */
			var validstatus = $("#commentForm").valid();
			if(validstatus)
	    	{
				$.dpAjax({
	 	    		url:'${basePath}/FkTmpCarRecheckController/vehicleDataReview',
	     			data:data,
	     			success: function(datas){
	    				 $('#id').val(datas.result);
	     				 if(commit) {
	     					 layer.msg("提交成功！", {icon: 6,time:1500});
		     				 setTimeout(function(){
		     					location.href='${basePath}/web/system/loaning/vehicleDataReview.jsp'; 
		     				 },1500);
	     				 } else {
	     					layer.msg("保存成功！", {icon: 6});
	     				 }
	                 }
	 	    	});
	    	}
	    }
    </script>
</body>
</html>
